﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace LockScreen
{
    public partial class CountDownForm : Form
    {
        public CountDownForm()
        {
            InitializeComponent();
        }

        private void CountDownForm_Load(object sender, EventArgs e)
        {
            this.TransparencyKey = this.BackColor;
        }

        public void UI_Refresh(object sender, EventArgs e)
        {
            this.Refresh();
            CoreHelper.DoTopMost(this.Handle);
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (msg.Msg == WinAPI.WM_KEYDOWN | msg.Msg == WinAPI.WM_SYSKEYDOWN)
            {
                switch (keyData)
                {
                    case Keys.Escape:
                        CoreHelper.DoExit();
                        break;
                    case Keys.Space:
                        if (MainHideForm.IsPause)
                        {
                            MainHideForm.IsPause = false;
                        }
                        else
                        {
                            MainHideForm.IsPause = true;
                        }
                        break;
                    case Keys.Enter:
                        CoreHelper.DoLock(this.Handle);
                        break;
                }
            }
            return false;
        }

        public void SetPicture(Image image)
        {
            this.pbxCountDown.BackgroundImage = image;
        }

        public void SetLoaction(Int32 x, Int32 y)
        {
            this.Location = new Point(x, y);
        }

        public void SetSize(Int32 width, Int32 height)
        {
            this.Size = new Size(width, height);
        }
    }
}
